package com.xckx.VisioViewer;

import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;
import java.awt.event.*;

import com.xckx.Visio.Interface.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2005</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class PaintPanel extends JPanel {

  private MainFrame main = null;
  private String fileName = null;
  private Color bkColor;

  public PaintPanel(MainFrame mainf,String file) {
    this.main = mainf;
    this.fileName = file;
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
    this.addMouseListener(main.getViewer());
    this.addMouseMotionListener(main.getViewer());
    this.addMouseListener(main);
  }

  private void jbInit() throws Exception {
    bkColor = main.getPanelBkColor();
    setBackground(bkColor);
    setForeground(bkColor);
  }

  public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D)g;
    g.setColor(bkColor);
    g.fillRect(0,0,this.getWidth(),this.getHeight());
    if (main.getViewer() != null)
      main.getViewer().draw(g2d);
  }

  public void update(Graphics g) {
    paint(g);
  }

  public void setBkColor(Color color) {
    bkColor = color;
    setBackground(bkColor);
    setForeground(bkColor);
    repaint();
  }

}











